﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication.Admin
{
    public partial class BaoCaoChiTheoNgay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!IsPostBack)
            {
                DateTime dt = DateTime.Now;
                DateTime dts = Commomcs.convertDate(dt.ToString("dd/MM/yyyy"));
                string ngay = dts.ToString("dd/MM/yyyy");
                datepicker.Text = dts.ToString("dd/MM/yyyy");
                var source = new Microsoft.Reporting.WebForms.ReportDataSource("BaoCaoChi", new Baocao.Chi().GetPhieuChi(dts,ngay));
                ReportViewer1.LocalReport.ReportPath = @"Admin\Baocao\BaoCaoChiTheoNgay.rdlc";
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.LocalReport.DataSources.Add(source);
                ReportViewer1.LocalReport.Refresh();
            }
        }

        protected void lbtnxem_Click(object sender, EventArgs e)
        {

            DateTime dt = Commomcs.convertDate(datepicker.Text);
            string ngay = dt.ToString("dd/MM/yyyyy");
            var source = new Microsoft.Reporting.WebForms.ReportDataSource("BaoCaoChi", new Baocao.Chi().GetPhieuChi(dt,ngay));
            if (string.IsNullOrEmpty(datepicker.Text))
            {
                RegisterClientScriptBlock("Thông báo", "<script> alert('Chưa nhập ngày')</script>");
                return;
            }
            ReportViewer1.LocalReport.ReportPath = @"Admin\Baocao\BaoCaoChiTheoNgay.rdlc";
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(source);
            ReportViewer1.LocalReport.Refresh();
        }
    }
}